package com.ysd.Servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.ysd.dao.impl.XiangXiXinWenDaoImpl;
import com.ysd.dao.impl.XinWenDaoimpl;
import com.ysd.entity.XiangXiXinWen;
import com.ysd.entity.XinWen;


public class NewsServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session=request.getSession();
		
		
		XinWenDaoimpl xwDao=new XinWenDaoimpl();//获得新闻分类的的实现类
		List<XinWen> lxw=xwDao.getXinWen();//获得新闻分类的实现类的数据
		session.setAttribute("lxw", lxw);//存数据到session
		
		XiangXiXinWenDaoImpl xxxwDao=new XiangXiXinWenDaoImpl();//获得通过xinWenId外键查询详细新闻的实现类
		int xwid=Integer.parseInt(request.getParameter("xinWenId"));//获得前台传来的参数
		ArrayList<XiangXiXinWen> lxxxw=xxxwDao.getXiangXiXinWen(xwid);//获得通过xinWenId外键查询详细新闻的实现类获得的数据
		session.setAttribute("lxxxw", lxxxw);//存数据到session
		request.setAttribute("lxxxw", lxxxw);//存数据到下个页面
		
		request.getRequestDispatcher("article_list.jsp").forward(request, response);
		
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
		
	}
	
	
	

}
